function value = getSample(I, y, x)
[sy sx z] = size(I);


if(y>sy)
    y = sy;
else if (y<=0)
        y = 1;
    end   
end

if(x>sx)
    x = sx;
else if (x<=0)
        x=1;
    end
end

value = I(y,x);